package actions;

import javax.ejb.EJB;
import java.util.*;
import entities.*;
import javax.ejb.Local;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import utils.*;
import beans.*;

public class EditAccountAction extends ActionSupport {

	private static final long serialVersionUID = 5L;

	private User user;
	@EJB
	private UserManagerLocal userMan;
	private String message;

	public String execute() {

		Object userIdObj = ActionContext.getContext().getSession()
				.get("userId");
		if (userIdObj == null)
			return ERROR;

		// Now load the user object
		userMan = new UserManager();
		user = userMan.getUser((Integer) userIdObj);
		if (user == null) {
			message = "Unable to locate account. Please login again";
			return ERROR;
		}

		return SUCCESS;

	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}